package print.folder.name.ui.adapter;

import android.content.Intent;
import android.net.Uri;

import com.blankj.utilcode.util.FileIOUtils;

import java.io.File;

import static com.blankj.utilcode.util.FileUtils.listFilesInDir;
import static com.blankj.utilcode.util.PathUtils.getExternalAppDownloadPath;

public final class tools {

    /*public static List<String> getFilesAllName(String path) {
        File file = new File(path);
        File[] files = file.listFiles();
        if (files == null) {
            Log.e("error", "空目录");
            return null;
        }
        List<String> s = new ArrayList<>();
        for (File value : files) {
            s.add(value.getName());
        }
        return s;
    }*/

    /**
     * 获取文件或文件的父路径
     **/
    public static String getParentPath(String pathStr) {
        File path = new File(pathStr);
        if (path.getParentFile() == null) {
            return null;
        } else {
            return path.getParent();
        }
    }


    public static void run_Path(final File file, final String name) {
        File[] files = file.listFiles();
        if (file.isDirectory()) {
            if (files != null) {
                for (File tempFile : files) {
                    run_Path(tempFile, name);
                }
            }
        } else {
            //Log.d("001", file.getAbsolutePath());
            FileIOUtils.writeFileFromString(getExternalAppDownloadPath() + "/" + name + ".txt", file.getName() + "\n", true);
        }

    }
}